<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>My Project: IOThreadStorage.h 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">My Project
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.8 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function() { init_codefold(0); });
/* @license-end */
</script>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">载入中...</div>
<div class="SRStatus" id="Searching">搜索中...</div>
<div class="SRStatus" id="NoMatches">未找到</div>
</div>
</div>
</div>
</div>

<div class="header">
  <div class="headertitle"><div class="title">IOThreadStorage.h</div></div>
</div><!--header-->
<div class="contents">
<a href="IOThreadStorage_8h.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span> </div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno">   15</span><span class="preprocessor">#pragma once</span></div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno">   16</span> </div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno">   17</span><span class="preprocessor">#include &lt;<a class="code" href="HttpAppFramework_8h.html">drogon/HttpAppFramework.h</a>&gt;</span></div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno">   18</span><span class="preprocessor">#include &lt;trantor/utils/NonCopyable.h&gt;</span></div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno">   19</span><span class="preprocessor">#include &lt;memory&gt;</span></div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno">   20</span><span class="preprocessor">#include &lt;vector&gt;</span></div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno">   21</span><span class="preprocessor">#include &lt;limits&gt;</span></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno">   22</span><span class="preprocessor">#include &lt;functional&gt;</span></div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno">   23</span> </div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno">   24</span><span class="keyword">namespace </span><a class="code hl_namespace" href="namespacedrogon.html">drogon</a></div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno">   25</span>{</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno">   59</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> C&gt;</div>
<div class="foldopen" id="foldopen00060" data-start="{" data-end="};">
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"><a class="line" href="classdrogon_1_1IOThreadStorage.html">   60</a></span><span class="keyword">class </span><a class="code hl_class" href="classdrogon_1_1IOThreadStorage.html">IOThreadStorage</a> : <span class="keyword">public</span> trantor::NonCopyable</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno">   61</span>{</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno">   62</span>  <span class="keyword">public</span>:</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"><a class="line" href="classdrogon_1_1IOThreadStorage.html#a99ea4e2087640afb5489cffb283486a2">   63</a></span>    <span class="keyword">using </span><a class="code hl_typedef" href="classdrogon_1_1IOThreadStorage.html#a99ea4e2087640afb5489cffb283486a2">ValueType</a> = C;</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"><a class="line" href="classdrogon_1_1IOThreadStorage.html#a7d9827ce9a95c8eedcb06ce760541d48">   64</a></span>    <span class="keyword">using </span><a class="code hl_typedef" href="classdrogon_1_1IOThreadStorage.html#a7d9827ce9a95c8eedcb06ce760541d48">InitCallback</a> = std::function&lt;void(<a class="code hl_typedef" href="classdrogon_1_1IOThreadStorage.html#a99ea4e2087640afb5489cffb283486a2">ValueType</a> &amp;, <span class="keywordtype">size_t</span>)&gt;;</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno">   65</span> </div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno">   66</span>    <span class="keyword">template</span> &lt;<span class="keyword">typename</span>... Args&gt;</div>
<div class="foldopen" id="foldopen00067" data-start="{" data-end="}">
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"><a class="line" href="classdrogon_1_1IOThreadStorage.html#a744b426884cbb4c04c12f52aa48f3bbc">   67</a></span>    <a class="code hl_function" href="classdrogon_1_1IOThreadStorage.html#a744b426884cbb4c04c12f52aa48f3bbc">IOThreadStorage</a>(Args &amp;&amp;...args)</div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno">   68</span>    {</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno">   69</span>        <span class="keyword">static_assert</span>(std::is_constructible&lt;C, Args &amp;&amp;...&gt;::value,</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno">   70</span>                      <span class="stringliteral">&quot;Unable to construct storage with given signature&quot;</span>);</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno">   71</span>        <span class="keywordtype">size_t</span> numThreads = <a class="code hl_function" href="namespacedrogon.html#a0be61eeb45a4c229be4041cd60d0d906">app</a>().<a class="code hl_function" href="classdrogon_1_1HttpAppFramework.html#add0bde17d0a16461a43cee523030e453">getThreadNum</a>();</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno">   72</span>        assert(numThreads &gt; 0 &amp;&amp;</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno">   73</span>               numThreads != (std::numeric_limits&lt;size_t&gt;::max)());</div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno">   74</span>        <span class="comment">// set the size to numThreads+1 to enable access to this in the main</span></div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno">   75</span>        <span class="comment">// thread.</span></div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno">   76</span>        storage_.reserve(numThreads + 1);</div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno">   77</span> </div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno">   78</span>        <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt;= numThreads; ++i)</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno">   79</span>        {</div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno">   80</span>            storage_.emplace_back(std::forward&lt;Args&gt;(args)...);</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno">   81</span>        }</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno">   82</span>    }</div>
</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno">   83</span> </div>
<div class="foldopen" id="foldopen00084" data-start="{" data-end="}">
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"><a class="line" href="classdrogon_1_1IOThreadStorage.html#aacd3dcefacbd09c3309d42f2f166e579">   84</a></span>    <span class="keywordtype">void</span> <a class="code hl_function" href="classdrogon_1_1IOThreadStorage.html#aacd3dcefacbd09c3309d42f2f166e579">init</a>(<span class="keyword">const</span> <a class="code hl_typedef" href="classdrogon_1_1IOThreadStorage.html#a7d9827ce9a95c8eedcb06ce760541d48">InitCallback</a> &amp;initCB)</div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno">   85</span>    {</div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno">   86</span>        <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; storage_.size(); ++i)</div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno">   87</span>        {</div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno">   88</span>            initCB(storage_[i], i);</div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno">   89</span>        }</div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno">   90</span>    }</div>
</div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno">   91</span> </div>
<div class="foldopen" id="foldopen00097" data-start="{" data-end="}">
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"><a class="line" href="classdrogon_1_1IOThreadStorage.html#a65cc6d82047caf8e3e5b9aed0f79ca16">   97</a></span>    <span class="keyword">inline</span> <a class="code hl_typedef" href="classdrogon_1_1IOThreadStorage.html#a99ea4e2087640afb5489cffb283486a2">ValueType</a> &amp;<a class="code hl_function" href="classdrogon_1_1IOThreadStorage.html#a65cc6d82047caf8e3e5b9aed0f79ca16">getThreadData</a>()</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno">   98</span>    {</div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno">   99</span>        <span class="keywordtype">size_t</span> idx = <a class="code hl_function" href="namespacedrogon.html#a0be61eeb45a4c229be4041cd60d0d906">app</a>().<a class="code hl_function" href="classdrogon_1_1HttpAppFramework.html#af59cc013141e80a539e3dc6d1d4423c5">getCurrentThreadIndex</a>();</div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno">  100</span>        assert(idx &lt; storage_.size());</div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno">  101</span>        <span class="keywordflow">return</span> storage_[idx];</div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno">  102</span>    }</div>
</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno">  103</span> </div>
<div class="foldopen" id="foldopen00104" data-start="{" data-end="}">
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno"><a class="line" href="classdrogon_1_1IOThreadStorage.html#a387588390a81f201731f3d989e8378d4">  104</a></span>    <span class="keyword">inline</span> <span class="keyword">const</span> <a class="code hl_typedef" href="classdrogon_1_1IOThreadStorage.html#a99ea4e2087640afb5489cffb283486a2">ValueType</a> &amp;<a class="code hl_function" href="classdrogon_1_1IOThreadStorage.html#a387588390a81f201731f3d989e8378d4">getThreadData</a>()<span class="keyword"> const</span></div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno">  105</span><span class="keyword">    </span>{</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno">  106</span>        <span class="keywordtype">size_t</span> idx = <a class="code hl_function" href="namespacedrogon.html#a0be61eeb45a4c229be4041cd60d0d906">app</a>().<a class="code hl_function" href="classdrogon_1_1HttpAppFramework.html#af59cc013141e80a539e3dc6d1d4423c5">getCurrentThreadIndex</a>();</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno">  107</span>        assert(idx &lt; storage_.size());</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno">  108</span>        <span class="keywordflow">return</span> storage_[idx];</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno">  109</span>    }</div>
</div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno">  110</span> </div>
<div class="foldopen" id="foldopen00116" data-start="{" data-end="}">
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"><a class="line" href="classdrogon_1_1IOThreadStorage.html#a31516d59aed4d5352a01877c2bd82361">  116</a></span>    <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classdrogon_1_1IOThreadStorage.html#a31516d59aed4d5352a01877c2bd82361">setThreadData</a>(<span class="keyword">const</span> <a class="code hl_typedef" href="classdrogon_1_1IOThreadStorage.html#a99ea4e2087640afb5489cffb283486a2">ValueType</a> &amp;newData)</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno">  117</span>    {</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno">  118</span>        <span class="keywordtype">size_t</span> idx = <a class="code hl_function" href="namespacedrogon.html#a0be61eeb45a4c229be4041cd60d0d906">app</a>().<a class="code hl_function" href="classdrogon_1_1HttpAppFramework.html#af59cc013141e80a539e3dc6d1d4423c5">getCurrentThreadIndex</a>();</div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno">  119</span>        assert(idx &lt; storage_.size());</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno">  120</span>        storage_[idx] = newData;</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno">  121</span>    }</div>
</div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno">  122</span> </div>
<div class="foldopen" id="foldopen00123" data-start="{" data-end="}">
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"><a class="line" href="classdrogon_1_1IOThreadStorage.html#afcf2d6a7d36c8d985ba57adc318f52a2">  123</a></span>    <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classdrogon_1_1IOThreadStorage.html#afcf2d6a7d36c8d985ba57adc318f52a2">setThreadData</a>(<a class="code hl_typedef" href="classdrogon_1_1IOThreadStorage.html#a99ea4e2087640afb5489cffb283486a2">ValueType</a> &amp;&amp;newData)</div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno">  124</span>    {</div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno">  125</span>        <span class="keywordtype">size_t</span> idx = <a class="code hl_function" href="namespacedrogon.html#a0be61eeb45a4c229be4041cd60d0d906">app</a>().<a class="code hl_function" href="classdrogon_1_1HttpAppFramework.html#af59cc013141e80a539e3dc6d1d4423c5">getCurrentThreadIndex</a>();</div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno">  126</span>        assert(idx &lt; storage_.size());</div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno">  127</span>        storage_[idx] = std::move(newData);</div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno">  128</span>    }</div>
</div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno">  129</span> </div>
<div class="foldopen" id="foldopen00130" data-start="{" data-end="}">
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"><a class="line" href="classdrogon_1_1IOThreadStorage.html#a2b65b8081973a7b15d824abcf0df8591">  130</a></span>    <span class="keyword">inline</span> <a class="code hl_typedef" href="classdrogon_1_1IOThreadStorage.html#a99ea4e2087640afb5489cffb283486a2">ValueType</a> *<a class="code hl_function" href="classdrogon_1_1IOThreadStorage.html#a2b65b8081973a7b15d824abcf0df8591">operator-&gt;</a>()</div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno">  131</span>    {</div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno">  132</span>        <span class="keywordtype">size_t</span> idx = <a class="code hl_function" href="namespacedrogon.html#a0be61eeb45a4c229be4041cd60d0d906">app</a>().<a class="code hl_function" href="classdrogon_1_1HttpAppFramework.html#af59cc013141e80a539e3dc6d1d4423c5">getCurrentThreadIndex</a>();</div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno">  133</span>        assert(idx &lt; storage_.size());</div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno">  134</span>        <span class="keywordflow">return</span> &amp;storage_[idx];</div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno">  135</span>    }</div>
</div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno">  136</span> </div>
<div class="foldopen" id="foldopen00137" data-start="{" data-end="}">
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno"><a class="line" href="classdrogon_1_1IOThreadStorage.html#a8bd1c4f7eeadb199d4a1e6c1d164b6cd">  137</a></span>    <span class="keyword">inline</span> <a class="code hl_typedef" href="classdrogon_1_1IOThreadStorage.html#a99ea4e2087640afb5489cffb283486a2">ValueType</a> &amp;<a class="code hl_function" href="classdrogon_1_1IOThreadStorage.html#a8bd1c4f7eeadb199d4a1e6c1d164b6cd">operator*</a>()</div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno">  138</span>    {</div>
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno">  139</span>        <span class="keywordflow">return</span> <a class="code hl_function" href="classdrogon_1_1IOThreadStorage.html#a65cc6d82047caf8e3e5b9aed0f79ca16">getThreadData</a>();</div>
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno">  140</span>    }</div>
</div>
<div class="line"><a id="l00141" name="l00141"></a><span class="lineno">  141</span> </div>
<div class="foldopen" id="foldopen00142" data-start="{" data-end="}">
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno"><a class="line" href="classdrogon_1_1IOThreadStorage.html#a04a8083b0833c03fb2f5522736876325">  142</a></span>    <span class="keyword">inline</span> <span class="keyword">const</span> <a class="code hl_typedef" href="classdrogon_1_1IOThreadStorage.html#a99ea4e2087640afb5489cffb283486a2">ValueType</a> *<a class="code hl_function" href="classdrogon_1_1IOThreadStorage.html#a04a8083b0833c03fb2f5522736876325">operator-&gt;</a>()<span class="keyword"> const</span></div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno">  143</span><span class="keyword">    </span>{</div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno">  144</span>        <span class="keywordtype">size_t</span> idx = <a class="code hl_function" href="namespacedrogon.html#a0be61eeb45a4c229be4041cd60d0d906">app</a>().<a class="code hl_function" href="classdrogon_1_1HttpAppFramework.html#af59cc013141e80a539e3dc6d1d4423c5">getCurrentThreadIndex</a>();</div>
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno">  145</span>        assert(idx &lt; storage_.size());</div>
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno">  146</span>        <span class="keywordflow">return</span> &amp;storage_[idx];</div>
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno">  147</span>    }</div>
</div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno">  148</span> </div>
<div class="foldopen" id="foldopen00149" data-start="{" data-end="}">
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno"><a class="line" href="classdrogon_1_1IOThreadStorage.html#a18a10e8496d63e13dedfd41044c5f921">  149</a></span>    <span class="keyword">inline</span> <span class="keyword">const</span> <a class="code hl_typedef" href="classdrogon_1_1IOThreadStorage.html#a99ea4e2087640afb5489cffb283486a2">ValueType</a> &amp;<a class="code hl_function" href="classdrogon_1_1IOThreadStorage.html#a18a10e8496d63e13dedfd41044c5f921">operator*</a>()<span class="keyword"> const</span></div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno">  150</span><span class="keyword">    </span>{</div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno">  151</span>        <span class="keywordflow">return</span> <a class="code hl_function" href="classdrogon_1_1IOThreadStorage.html#a65cc6d82047caf8e3e5b9aed0f79ca16">getThreadData</a>();</div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno">  152</span>    }</div>
</div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno">  153</span> </div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno">  154</span>  <span class="keyword">private</span>:</div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno">  155</span>    std::vector&lt;ValueType&gt; storage_;</div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno">  156</span>};</div>
</div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno">  157</span> </div>
<div class="foldopen" id="foldopen00158" data-start="{" data-end="}">
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno"><a class="line" href="namespacedrogon.html#a6ea98bf773b9b5b1ef8ce354997f25e9">  158</a></span><span class="keyword">inline</span> trantor::EventLoop *<a class="code hl_function" href="namespacedrogon.html#a6ea98bf773b9b5b1ef8ce354997f25e9">getIOThreadStorageLoop</a>(<span class="keywordtype">size_t</span> index) <span class="keyword">noexcept</span>(<span class="keyword">false</span>)</div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno">  159</span>{</div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno">  160</span>    <span class="keywordflow">if</span> (index &gt; <a class="code hl_function" href="namespacedrogon.html#a0be61eeb45a4c229be4041cd60d0d906">drogon::app</a>().<a class="code hl_function" href="classdrogon_1_1HttpAppFramework.html#add0bde17d0a16461a43cee523030e453">getThreadNum</a>())</div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno">  161</span>    {</div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno">  162</span>        <span class="keywordflow">throw</span> std::out_of_range(<span class="stringliteral">&quot;Event loop index is out of range&quot;</span>);</div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno">  163</span>    }</div>
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno">  164</span>    <span class="keywordflow">if</span> (index == <a class="code hl_function" href="namespacedrogon.html#a0be61eeb45a4c229be4041cd60d0d906">drogon::app</a>().getThreadNum())</div>
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno">  165</span>        <span class="keywordflow">return</span> <a class="code hl_function" href="namespacedrogon.html#a0be61eeb45a4c229be4041cd60d0d906">drogon::app</a>().<a class="code hl_function" href="classdrogon_1_1HttpAppFramework.html#af82887957c3f04200ac23d7f8add9128">getLoop</a>();</div>
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno">  166</span>    <span class="keywordflow">return</span> <a class="code hl_function" href="namespacedrogon.html#a0be61eeb45a4c229be4041cd60d0d906">drogon::app</a>().<a class="code hl_function" href="classdrogon_1_1HttpAppFramework.html#a9fa6352150ac9d3a76b621a2abdc2774">getIOLoop</a>(index);</div>
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno">  167</span>}</div>
</div>
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno">  168</span>}  <span class="comment">// namespace drogon</span></div>
<div class="ttc" id="aHttpAppFramework_8h_html"><div class="ttname"><a href="HttpAppFramework_8h.html">HttpAppFramework.h</a></div></div>
<div class="ttc" id="aclassdrogon_1_1HttpAppFramework_html_a9fa6352150ac9d3a76b621a2abdc2774"><div class="ttname"><a href="classdrogon_1_1HttpAppFramework.html#a9fa6352150ac9d3a76b621a2abdc2774">drogon::HttpAppFramework::getIOLoop</a></div><div class="ttdeci">virtual trantor::EventLoop * getIOLoop(size_t id) const =0</div><div class="ttdoc">Get an IO loop with id. E.g. 0 &lt;= id &lt; #Total thread-loops</div></div>
<div class="ttc" id="aclassdrogon_1_1HttpAppFramework_html_add0bde17d0a16461a43cee523030e453"><div class="ttname"><a href="classdrogon_1_1HttpAppFramework.html#add0bde17d0a16461a43cee523030e453">drogon::HttpAppFramework::getThreadNum</a></div><div class="ttdeci">virtual size_t getThreadNum() const =0</div><div class="ttdoc">Get the number of threads for IO event loops</div></div>
<div class="ttc" id="aclassdrogon_1_1HttpAppFramework_html_af59cc013141e80a539e3dc6d1d4423c5"><div class="ttname"><a href="classdrogon_1_1HttpAppFramework.html#af59cc013141e80a539e3dc6d1d4423c5">drogon::HttpAppFramework::getCurrentThreadIndex</a></div><div class="ttdeci">virtual size_t getCurrentThreadIndex() const =0</div><div class="ttdoc">Get the Current Thread Index whose range is [0, the total number of IO threads]</div></div>
<div class="ttc" id="aclassdrogon_1_1HttpAppFramework_html_af82887957c3f04200ac23d7f8add9128"><div class="ttname"><a href="classdrogon_1_1HttpAppFramework.html#af82887957c3f04200ac23d7f8add9128">drogon::HttpAppFramework::getLoop</a></div><div class="ttdeci">virtual trantor::EventLoop * getLoop() const =0</div><div class="ttdoc">Get the main event loop of the framework;</div></div>
<div class="ttc" id="aclassdrogon_1_1IOThreadStorage_html"><div class="ttname"><a href="classdrogon_1_1IOThreadStorage.html">drogon::IOThreadStorage</a></div><div class="ttdoc">Utility class for thread storage handling</div><div class="ttdef"><b>Definition</b> IOThreadStorage.h:61</div></div>
<div class="ttc" id="aclassdrogon_1_1IOThreadStorage_html_a04a8083b0833c03fb2f5522736876325"><div class="ttname"><a href="classdrogon_1_1IOThreadStorage.html#a04a8083b0833c03fb2f5522736876325">drogon::IOThreadStorage::operator-&gt;</a></div><div class="ttdeci">const ValueType * operator-&gt;() const</div><div class="ttdef"><b>Definition</b> IOThreadStorage.h:142</div></div>
<div class="ttc" id="aclassdrogon_1_1IOThreadStorage_html_a18a10e8496d63e13dedfd41044c5f921"><div class="ttname"><a href="classdrogon_1_1IOThreadStorage.html#a18a10e8496d63e13dedfd41044c5f921">drogon::IOThreadStorage::operator*</a></div><div class="ttdeci">const ValueType &amp; operator*() const</div><div class="ttdef"><b>Definition</b> IOThreadStorage.h:149</div></div>
<div class="ttc" id="aclassdrogon_1_1IOThreadStorage_html_a2b65b8081973a7b15d824abcf0df8591"><div class="ttname"><a href="classdrogon_1_1IOThreadStorage.html#a2b65b8081973a7b15d824abcf0df8591">drogon::IOThreadStorage::operator-&gt;</a></div><div class="ttdeci">ValueType * operator-&gt;()</div><div class="ttdef"><b>Definition</b> IOThreadStorage.h:130</div></div>
<div class="ttc" id="aclassdrogon_1_1IOThreadStorage_html_a31516d59aed4d5352a01877c2bd82361"><div class="ttname"><a href="classdrogon_1_1IOThreadStorage.html#a31516d59aed4d5352a01877c2bd82361">drogon::IOThreadStorage::setThreadData</a></div><div class="ttdeci">void setThreadData(const ValueType &amp;newData)</div><div class="ttdoc">Sets the thread data for the current thread</div><div class="ttdef"><b>Definition</b> IOThreadStorage.h:116</div></div>
<div class="ttc" id="aclassdrogon_1_1IOThreadStorage_html_a387588390a81f201731f3d989e8378d4"><div class="ttname"><a href="classdrogon_1_1IOThreadStorage.html#a387588390a81f201731f3d989e8378d4">drogon::IOThreadStorage::getThreadData</a></div><div class="ttdeci">const ValueType &amp; getThreadData() const</div><div class="ttdef"><b>Definition</b> IOThreadStorage.h:104</div></div>
<div class="ttc" id="aclassdrogon_1_1IOThreadStorage_html_a65cc6d82047caf8e3e5b9aed0f79ca16"><div class="ttname"><a href="classdrogon_1_1IOThreadStorage.html#a65cc6d82047caf8e3e5b9aed0f79ca16">drogon::IOThreadStorage::getThreadData</a></div><div class="ttdeci">ValueType &amp; getThreadData()</div><div class="ttdoc">Get the thread storage associate with the current thread</div><div class="ttdef"><b>Definition</b> IOThreadStorage.h:97</div></div>
<div class="ttc" id="aclassdrogon_1_1IOThreadStorage_html_a744b426884cbb4c04c12f52aa48f3bbc"><div class="ttname"><a href="classdrogon_1_1IOThreadStorage.html#a744b426884cbb4c04c12f52aa48f3bbc">drogon::IOThreadStorage::IOThreadStorage</a></div><div class="ttdeci">IOThreadStorage(Args &amp;&amp;...args)</div><div class="ttdef"><b>Definition</b> IOThreadStorage.h:67</div></div>
<div class="ttc" id="aclassdrogon_1_1IOThreadStorage_html_a7d9827ce9a95c8eedcb06ce760541d48"><div class="ttname"><a href="classdrogon_1_1IOThreadStorage.html#a7d9827ce9a95c8eedcb06ce760541d48">drogon::IOThreadStorage::InitCallback</a></div><div class="ttdeci">std::function&lt; void(ValueType &amp;, size_t)&gt; InitCallback</div><div class="ttdef"><b>Definition</b> IOThreadStorage.h:64</div></div>
<div class="ttc" id="aclassdrogon_1_1IOThreadStorage_html_a8bd1c4f7eeadb199d4a1e6c1d164b6cd"><div class="ttname"><a href="classdrogon_1_1IOThreadStorage.html#a8bd1c4f7eeadb199d4a1e6c1d164b6cd">drogon::IOThreadStorage::operator*</a></div><div class="ttdeci">ValueType &amp; operator*()</div><div class="ttdef"><b>Definition</b> IOThreadStorage.h:137</div></div>
<div class="ttc" id="aclassdrogon_1_1IOThreadStorage_html_a99ea4e2087640afb5489cffb283486a2"><div class="ttname"><a href="classdrogon_1_1IOThreadStorage.html#a99ea4e2087640afb5489cffb283486a2">drogon::IOThreadStorage::ValueType</a></div><div class="ttdeci">C ValueType</div><div class="ttdef"><b>Definition</b> IOThreadStorage.h:63</div></div>
<div class="ttc" id="aclassdrogon_1_1IOThreadStorage_html_aacd3dcefacbd09c3309d42f2f166e579"><div class="ttname"><a href="classdrogon_1_1IOThreadStorage.html#aacd3dcefacbd09c3309d42f2f166e579">drogon::IOThreadStorage::init</a></div><div class="ttdeci">void init(const InitCallback &amp;initCB)</div><div class="ttdef"><b>Definition</b> IOThreadStorage.h:84</div></div>
<div class="ttc" id="aclassdrogon_1_1IOThreadStorage_html_afcf2d6a7d36c8d985ba57adc318f52a2"><div class="ttname"><a href="classdrogon_1_1IOThreadStorage.html#afcf2d6a7d36c8d985ba57adc318f52a2">drogon::IOThreadStorage::setThreadData</a></div><div class="ttdeci">void setThreadData(ValueType &amp;&amp;newData)</div><div class="ttdef"><b>Definition</b> IOThreadStorage.h:123</div></div>
<div class="ttc" id="anamespacedrogon_html"><div class="ttname"><a href="namespacedrogon.html">drogon</a></div><div class="ttdoc">Drogon Test is a minimal effort test framework developed because the major C++ test frameworks doesn'...</div><div class="ttdef"><b>Definition</b> Attribute.h:23</div></div>
<div class="ttc" id="anamespacedrogon_html_a0be61eeb45a4c229be4041cd60d0d906"><div class="ttname"><a href="namespacedrogon.html#a0be61eeb45a4c229be4041cd60d0d906">drogon::app</a></div><div class="ttdeci">HttpAppFramework &amp; app()</div><div class="ttdoc">A wrapper of the instance() method</div><div class="ttdef"><b>Definition</b> HttpAppFramework.h:1656</div></div>
<div class="ttc" id="anamespacedrogon_html_a6ea98bf773b9b5b1ef8ce354997f25e9"><div class="ttname"><a href="namespacedrogon.html#a6ea98bf773b9b5b1ef8ce354997f25e9">drogon::getIOThreadStorageLoop</a></div><div class="ttdeci">trantor::EventLoop * getIOThreadStorageLoop(size_t index) noexcept(false)</div><div class="ttdef"><b>Definition</b> IOThreadStorage.h:158</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8
</small></address>
</body>
</html>
